package tas.co.in.daoimpl.roleAuthInfo;

import java.util.List;
import java.util.StringTokenizer;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import tas.co.in.dao.roleAuthInfo.roleAuthInfo;
import tas.co.in.domain.roleAuthInfo.roleAuthInfoBean;

public class roleAuthInfoImpl extends SqlMapClientDaoSupport implements roleAuthInfo
{
	public List<roleAuthInfoBean> getRoleAuthority()
	{
		try 
		{
			roleAuthInfoBean bean = new roleAuthInfoBean();
			bean.setGrpCode("USRROL");
			return getSqlMapClient().queryForList("roleAuthInfo.role", bean);
		}
		catch (Exception e) 
		{
			System.out.println(e);
		}
		return null;
	}
	
	public List<roleAuthInfo> getRoleDesc(roleAuthInfoBean bean)
	{
		try 
		{
			return getSqlMapClient().queryForList("roleAuthInfo.desc", bean);
		}
		catch (Exception e) 
		{
			System.out.println(e);
		}
		return null;
	}
	
	public boolean approveRole(final StringTokenizer items, roleAuthInfoBean bean)
	{
		boolean flag = false;
		try 
		{
			while(items.hasMoreTokens())
			{
				bean.setCode(items.nextToken());
//				bean.setDescription(items.nextToken());
				getSqlMapClient().insert("roleAuthInfo.assignRole", bean);
				flag = true;
			}
		}
		catch (Exception e) 
		{
			System.out.println(e);
		}
		return flag;
	}
}
